package com.train.pattern.strategy.v2.pay.way;


import java.util.HashMap;
import java.util.Map;

/**
 * @author hugx
 * @create 2021-01-15 14:02
 */
public class PayStrategyFactory {
    private static final String ALI_PAY="AliPay";
    private static final String WECHAT_PAY="WechatPay";
    private static final String UNION_PAY="UnionPay";
    private static final String JD_PAY="JdPay";
    private static final String DEFAULT_PAY=ALI_PAY;


    private static Map<String,PayStrategy> payStrategyMap=new HashMap<>();

    static {
       payStrategyMap.put(ALI_PAY,new AliPayStrategy());
    }

    /**
     * 获取具体的支付方式对象
     * @param payWay
     * @return
     */
    public static PayStrategy getPayStrategy(String payWay){
        if(null == payWay || "".equals(payWay)  || payStrategyMap.containsKey(payWay)){
            return payStrategyMap.get(DEFAULT_PAY);

        }

        return payStrategyMap.get(payWay);
    }


}
